Stored Procedures [dbo].[aspnet_Profile_DeleteInactiveProfiles]
Properties
PropertyValue
ANSI Nulls OnNo
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@ApplicationNamenvarchar(256)512
@ProfileAuthOptionsint4
@InactiveSinceDatedatetime8
Permissions
TypeActionOwning Principal
GrantExecuteaspnet_Profile_FullAccess
SQL Script
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE dbo.aspnet_Profile_DeleteInactiveProfiles
    @ApplicationName        nvarchar(256),
    @ProfileAuthOptions     int,
    @InactiveSinceDate      datetime
AS
BEGIN
    DECLARE @ApplicationId uniqueidentifier
    SELECT  @ApplicationId = NULL
    SELECT  @ApplicationId = ApplicationId FROM aspnet_Applications WHERE LOWER(@ApplicationName) = LoweredApplicationName
    IF (@ApplicationId IS NULL)
    BEGIN
        SELECT  0
        RETURN
    END

    DELETE
    FROM    dbo.aspnet_Profile
    WHERE   UserId IN
            (   SELECT  UserId
                FROM    dbo.aspnet_Users u
                WHERE   ApplicationId = @ApplicationId
                        AND (LastActivityDate <= @InactiveSinceDate)
                        AND (
                                (@ProfileAuthOptions = 2)
                             OR (@ProfileAuthOptions = 0 AND IsAnonymous = 1)
                             OR (@ProfileAuthOptions = 1 AND IsAnonymous = 0)
                            )
            )

    SELECT  @@ROWCOUNT
END
GO
GRANT EXECUTE ON  [dbo].[aspnet_Profile_DeleteInactiveProfiles] TO [aspnet_Profile_FullAccess]
GO
Uses